# -*- coding:utf-8 -*-
"""
该脚本计算每个阶段提交cgtw工程文件的路径

ani: 动画阶段
    shot镜头任务:
       提交mov目录:
            netpath/Shot_work/Animation/eps/shot/
       提交ma文件目录:
            netpath/Shot_work/Animation/eps/shot/maya_file/
       提交abc文件目录:
            netpath/Shot_work/Animation/eps/shot/abc/
            abcname = shot_abc_version
            其中该目录下提交的是一个镜头号加版本命名的目录，目录里面可以加任意abc文件或其他文件

    asset资产任务:
       提交asset目录：
        netpath/Asset_work/Animation/  资产以资产名称命名的文件夹
            目录中有ma,abc,mov文件
            abc现在改为abc目录

rig: 绑定阶段
    绑定仅资产任务
    提交ma文件
    netpath/Asset_work/Rig/
        ma = asset_name_taskname_version.ma



mm：跟踪阶段
    跟踪仅有镜头任务
       提交mov目录:
            netpath/Shot_work/Matchmove/eps/
               跟踪的mov与ma直接提交到eps下面

      提交ma目录:
            netpath/Shot_work/Matchmove/eps/
               跟踪的ma,mov与ma直接提交到eps下面
               ma_name : shot_taskname_version.ma

       提交fbx目录:
               netpath/Shot_work/Matchmove/eps/
               跟踪的ma,mov与ma直接提交到eps下面
               fbx_name : shot_taskname_version.fbx

       提交abc目录:
            netpath/Shot_work/Matchmove/eps/abc
               跟踪的abc提交到abc目录下面以 shot_taskname_abc_version.abc命名

       提交畸变图序列目录:
            netpath/Shot_work/Matchmove/eps/
               畸变图序列在eps下 以 shot_ud命名，在里面序列图目录以shot_ud_version命令
               ud : shotname_ud_version
               输出的图片为jpg格式，且以shot名称命名




lgt:灯光阶段
    灯光镜头任务
    提交mov目录:
        netpath/Shot_work/Light/eps/lgt_media/
            mov_name : shot_taskname_version.mov

    提交单帧目录:
        netpath/Shot_work/Light/eps/lgt_media/lgt_pic/
            img_name : shot_taskname_version.jpg

    提交ma目录:
        netpath/Shot_work/Light/eps/shot/
            在对应的shot下：
            ma ： shot_taskname_version.ma
            渲染序列: shot_taskname_version  目录名称



"""

import os

try:
    import maya.cmds as cmds
    # import maya.mel as mel
    # import pymel.core as pm
except Exception as test_ERR:
    print('test')


def getCgtwTexturePath(netpath,asset_name):
    """
    仅模型需要
    获取所有贴图路径.注意UDIM贴图路径。
    :return: {'file1':(local_tex_path,cgtw_tex_path,cgtw_tx_path),'file2':(),...}
    """
    dir_path = os.path.join(netpath, 'Asset_work', 'Texture', asset_name)

    files = cmds.ls(type='file')
    tex_path_map = {}
    if files:
        for f in files:
            local_tex_path = cmds.getAttr(f + '.fileTextureName')
            uvTilingMode = cmds.getAttr(f+'.uvTilingMode')
          
            if os.path.exists(local_tex_path):
                tex_dir, tex_full_name = os.path.split(local_tex_path)

                
                if uvTilingMode != 3:  # 非UDIM
                    tex_name, img_type = os.path.splitext(tex_full_name)
                    cgtw_tex_path = os.path.join(dir_path, tex_full_name)
                    local_tx_path = os.path.join(tex_dir,tex_name+'.tx')
                    cgtw_tx_path = ''
                    if os.path.exists(local_tx_path):
                        cgtw_tx_path = os.path.join(dir_path,tex_name+'.tx')
                    tex_path_map[f] = (local_tex_path,cgtw_tex_path,cgtw_tx_path)
                    tex_path_map[f] = [{'local_tex_path':local_tex_path,'cgtw_tex_path':cgtw_tex_path,
                                       'local_tx_path':local_tx_path,'cgtw_tx_path':cgtw_tx_path}]
                else:  #UDIM
                    tex_pre = tex_full_name.split('100')[0]
                    tex_uidim_tex = [i for i in os.listdir(tex_dir) if tex_pre in i]
                    # print('tex_uidim_tex:',tex_uidim_tex)
                    imgs_list = []
                    for o in tex_uidim_tex:
                        tex_name, img_type = os.path.splitext(o)
                        cgtw_tex_path = os.path.join(dir_path, o)
                        local_tex_path = os.path.join(tex_dir,o)
                        local_tx_path = os.path.join(tex_dir, tex_name + '.tx')
                        cgtw_tx_path = ''
                        if os.path.exists(local_tx_path):
                            cgtw_tx_path = os.path.join(dir_path, tex_name + '.tx')
                        imgs_list.append({'local_tex_path': local_tex_path, 'cgtw_tex_path': cgtw_tex_path,
                         'local_tx_path': local_tx_path, 'cgtw_tx_path': cgtw_tx_path})
                    # print('imgs_list:',imgs_list)
                    tex_path_map[f] = imgs_list

    return tex_path_map


def setCgtwTexturePath(netpath,asset_name):
    """
    重新将材质上的贴图路径设置为网盘路径
    :param tex_path_map:
    :return:
    """
    dir_path = os.path.join(netpath, 'Asset_work', 'Texture', asset_name)
    files = cmds.ls(type='file')
    if files:
        for f in files:
            local_tex_path = cmds.getAttr(f + '.fileTextureName')
            if os.path.exists(local_tex_path):
                tex_dir, tex_full_name = os.path.split(local_tex_path)
                cgtw_tex_path = os.path.join(dir_path,tex_full_name)
                cmds.setAttr(f + '.fileTextureName',cgtw_tex_path,type='string')

def getCgtwAssetPath(pipeline,netpath,asset_name,task_name,version):
    """
    获取各阶段资产提交路径
    每个阶段的资产返回路径种类不同，返回路径不同
    :param pipeline: 阶段名称
    :return:
    """
    path_data = {}

    if pipeline == 'ani':
        dir_path = os.path.join(netpath, 'Asset_work', 'Animation', asset_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name,task_name,version)
        ma_path = os.path.join(dir_path,ma_name)
        abc_folder_name = '{}_{}_abc_{}'.format(asset_name,task_name,version)
        abc_path = os.path.join(dir_path,abc_folder_name)
        mov_name = '{}_{}_{}.mov'.format(asset_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        path_data['dir_path'] = dir_path
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['abc_name'] = abc_folder_name
        path_data['ma_name'] = ma_name


    elif pipeline == 'rig':
        dir_path = os.path.join(netpath, 'Asset_work', 'Rig', asset_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name,task_name,version)
        ma_path = os.path.join(dir_path, ma_name)
        path_data['dir_path'] = dir_path
        path_data['ma_path'] = ma_path
        path_data['ma_name'] = ma_name

    elif pipeline == 'env':
        dir_path = os.path.join(netpath, 'Asset_work', 'Environment', asset_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name,task_name,version)
        ma_path = os.path.join(dir_path,ma_name)
        abc_folder_name = '{}_{}_abc_{}'.format(asset_name,task_name,version)
        abc_path = os.path.join(dir_path,abc_folder_name)
        mov_name = '{}_{}_{}.mov'.format(asset_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        path_data['dir_path'] = dir_path
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['abc_name'] = abc_folder_name
        path_data['ma_name'] = ma_name

    elif pipeline == 'mod':
        dir_path = os.path.join(netpath, 'Asset_work', 'Model',asset_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name, task_name, version)
        ma_path = os.path.join(dir_path,ma_name)
        mov_name = '{}_{}_{}.mov'.format(asset_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        img_name = '{}_{}_{}.jpg'.format(asset_name, task_name, version)
        img_path = os.path.join(dir_path,img_name)
        tex_path = getCgtwTexturePath(netpath,asset_name)

        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['ma_path'] = ma_path
        path_data['img_path'] = img_path
        path_data['ma_name'] = ma_name
        path_data['img_name'] = img_name
        path_data['tex_path'] = tex_path

    elif pipeline == 'lgt':
        dir_path = os.path.join(netpath, 'Asset_work', 'Light', asset_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name,task_name,version)
        ma_path = os.path.join(dir_path,ma_name)
        madir_name = '{}_{}_{}'.format(asset_name, task_name, version) # 灯光提交ma目录
        madir_path = os.path.join(dir_path,madir_name)
        mov_name = '{}_{}_{}.mov'.format(asset_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        path_data['dir_path'] = dir_path
        path_data['ma_path'] = ma_path
        path_data['ma_name'] = ma_name
        path_data['madir_path'] = madir_path
        path_data['madir_name'] = madir_name
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name

    elif pipeline == 'cfx':
        dir_path = os.path.join(netpath, 'Asset_work', 'CFX', asset_name)
        mov_name = '{}_{}_{}.mov'.format(asset_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        ma_name = '{}_{}_{}.ma'.format(asset_name, task_name, version)
        ma_path = os.path.join(dir_path,'maya_file',ma_name)
        abc_dir_name = '{}_{}_abc_{}'.format(asset_name,task_name,version)
        abc_path = os.path.join(dir_path,'abc',abc_dir_name)  # abc是一个目录
        fbx_name = '{}_{}_fbx_{}'.format(asset_name, task_name, version) # fbx也是一个目录
        fbx_path = os.path.join(dir_path,'fbx',fbx_name)
        tex_path = getCgtwTexturePath(netpath, asset_name)
        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['ma_name'] = ma_name
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['abc_name'] = abc_dir_name
        path_data['fbx_name'] = fbx_name
        path_data['fbx_path'] = fbx_path
        path_data['tex_path'] = tex_path

    return path_data



def getCgtwShotPath(pipeline,netpath,eps,shot_name,task_name,version):
    """
    获取各阶段镜头提交任务路径
    :param pipeline:
    :param netpath:
    :param eps:
    :param shot_name:
    :param task_name:
    :param version:
    :return:
    """
    path_data = {}
    if pipeline == 'ani':
        dir_path = os.path.join(netpath, 'Shot_work', 'Animation',eps,shot_name)
        mov_name = '{}_{}_{}.mov'.format(shot_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        ma_name = '{}_{}_{}.ma'.format(shot_name, task_name, version)
        ma_path = os.path.join(dir_path,'maya_file',ma_name)
        abc_dir_name = '{}_{}_abc_{}'.format(shot_name,task_name,version)
        abc_path = os.path.join(dir_path,'abc',abc_dir_name)  # abc是一个目录
        path_data['dir_path'] = dir_path
        path_data['ma_path'] = ma_path
        path_data['mov_path'] = mov_path
        path_data['abc_path'] = abc_path
        path_data['ma_name'] = ma_name
        path_data['mov_name'] = mov_name
        path_data['abc_name'] = abc_dir_name

    elif pipeline == 'mm':
        dir_path = os.path.join(netpath, 'Shot_work', 'Matchmove', eps) # 跟踪文件都在集数下面
        mov_name = '{}_{}_{}.mov'.format(shot_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        ma_name = '{}_{}_{}.ma'.format(shot_name, task_name, version)
        ma_path = os.path.join(dir_path,'maya_file',ma_name)
        fbx_name = '{}_{}_{}.fbx'.format(shot_name, task_name, version)
        fbx_path = os.path.join(dir_path,'fbx',fbx_name)
        abc_name = '{}_{}_abc_{}'.format(shot_name, task_name, version)
        abc_path = os.path.join(dir_path,'abc',abc_name)
        ud_name = '{}_ud_{}'.format(shot_name, version)  # 这里的ud是一个目录
        ud_dir_name = '{}_ud'.format(shot_name, version)
        ud_path = os.path.join(dir_path,ud_dir_name,ud_name)
        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['ud_path'] = ud_path
        path_data['ma_name'] = ma_name
        path_data['fbx_name'] = fbx_name
        path_data['fbx_path'] = fbx_path
        path_data['mov_name'] = mov_name
        path_data['ud_name'] = ud_name
        path_data['abc_name'] = abc_name

    elif pipeline == 'env':
        dir_path = os.path.join(netpath, 'Shot_work', 'Environment', eps,shot_name)
        mov_name = '{}_{}_{}.mov'.format(shot_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        ma_name = '{}_{}_{}.ma'.format(shot_name, task_name, version)
        ma_path = os.path.join(dir_path,'maya_file',ma_name)
        abc_dir_name = '{}_{}_abc_{}'.format(shot_name,task_name,version)
        abc_path = os.path.join(dir_path,'abc',abc_dir_name)  # abc是一个目录
        fbx_name = '{}_{}_fbx_{}'.format(shot_name, task_name, version) # fbx也是一个目录
        fbx_path = os.path.join(dir_path,'fbx',fbx_name)
        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['ma_name'] = ma_name
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['abc_name'] = abc_dir_name
        path_data['fbx_name'] = fbx_name
        path_data['fbx_path'] = fbx_path

    elif pipeline == 'cfx':
        dir_path = os.path.join(netpath, 'Shot_work', 'CFX', eps,shot_name)
        mov_name = '{}_{}_{}.mov'.format(shot_name,task_name,version)
        mov_path = os.path.join(dir_path,mov_name)
        ma_name = '{}_{}_{}.ma'.format(shot_name, task_name, version)
        ma_path = os.path.join(dir_path,'maya_file',ma_name)
        abc_dir_name = '{}_{}_abc_{}'.format(shot_name,task_name,version)
        abc_path = os.path.join(dir_path,'abc',abc_dir_name)  # abc是一个目录
        fbx_name = '{}_{}_fbx_{}'.format(shot_name, task_name, version) # fbx也是一个目录
        fbx_path = os.path.join(dir_path,'fbx',fbx_name)
        tex_path = getCgtwTexturePath(netpath, shot_name)
        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['mov_name'] = mov_name
        path_data['ma_name'] = ma_name
        path_data['ma_path'] = ma_path
        path_data['abc_path'] = abc_path
        path_data['abc_name'] = abc_dir_name
        path_data['fbx_name'] = fbx_name
        path_data['fbx_path'] = fbx_path
        path_data['tex_path'] = tex_path

    elif pipeline == 'lgt':
        dir_path = os.path.join(netpath, 'Shot_work', 'Light', eps,shot_name)
        media_path = os.path.join(netpath, 'Shot_work', 'Light', eps,'lgt_media')
        mov_name = '{}_{}_{}.mov'.format(shot_name,task_name,version)
        mov_path = os.path.join(media_path, mov_name)
        img_name = '{}_{}_{}.jpg'.format(shot_name,task_name,version)
        img_path = os.path.join(media_path,'lgt_pic',img_name)
        ma_name = '{}_{}_{}.ma'.format(shot_name, task_name, version)
        ma_path = os.path.join(dir_path, ma_name)
        madir_name = '{}_{}_{}'.format(shot_name, task_name, version) # 灯光提交ma目录
        madir_path = os.path.join(dir_path,madir_name)
        render_name = '{}_{}_{}'.format(shot_name,task_name,version)  # 渲染文件目录，里面是各渲染层
        render_path = os.path.join(dir_path,render_name)
        path_data['dir_path'] = dir_path
        path_data['mov_path'] = mov_path
        path_data['img_path'] = img_path
        path_data['ma_path'] = ma_path
        path_data['ma_name'] = ma_name
        path_data['madir_path'] = madir_path
        path_data['madir_name'] = madir_name
        path_data['mov_name'] = mov_name
        path_data['img_name'] = img_name
        path_data['render_name'] = render_name
        path_data['render_path'] = render_path




    return path_data


def get_cgtw_data(cgtw_path, eps, asset_shot_name, pipeline):
    """
    获取关联阶段的文件,仅shot任务才有关联
    :param cgtw_path:
    :param eps:
    :param asset_shot_name:
    :param pipeline:
    :return: data  为输出字典信息。 定义如下：
        当查询的是mm阶段，需要
            {'pipeline':'mm','mm_path':Matchmove/eps目录,'ma_list':[ma文件所在层级所有文件包括图片，mov经过shot_name过滤的],
             'abc':abc目录,'abc_list':[abc目录下对应镜头的的abc文件]}
        mod：
            {'pipeline':'mod','mod_path':Model目录,'mod_dirs':[dirs],'tex_path':Texture目录,'tex_dirs':[Texture目录下的abc]}
        rig：
            {'pipeline':'rig','rig_path':Rig目录,'rig_dirs':[dirs]}

        env：
            {'pipeline':'env','abc_path':abc目录(以shot_name过滤过),'abc_dirs':[dirs]}

       ani：
            {'pipeline':'ani','asset_path':Asset/Animation目录,'asset_dirs':[dirs],
            'shot_path':Shot镜头对应目录,'ma_list':[Shot目录下的ma],
            'abc_path':Shot镜头对应目录下的abc目录,'abc_dirs':[对应的各版本abc目录]}
    """
    data = {}
    if eps == 'Asset':
        return None

    if pipeline == 'mm':  # 查跟踪有关系的窗口内容,

        mm_path = os.path.join(cgtw_path, 'Shot_work', 'Matchmove', eps)
        data = {'pipeline': 'mm', 'mm_path': '', 'ma_list': [], 'abc_path': '',
                'abc_list': []}  # {'pipeline':'mm','mm_path':Matchmove/eps目录,'ma_list':[ma文件所在层级所有文件包括图片，mov经过shot_name过滤的],
        # 'abc':abc目录,'abc_list':[abc目录下对应镜头的的abc文件]}
        if os.path.exists(mm_path):
            maya_file_path = os.path.join(mm_path,'maya_file')
            data['mm_path'] = mm_path
            data['maya_file_path'] = maya_file_path
            ma_file_list = os.listdir(maya_file_path)
            ma_list = []
            for ma_file in ma_file_list:
                file_path = os.path.join(maya_file_path, ma_file)
                if os.path.isfile(file_path) and ma_file.startswith(asset_shot_name):
                    ma_list.append(ma_file)
            data['ma_list'] = ma_list

            abc_path = os.path.join(mm_path, 'abc')
            data['abc_path'] = abc_path
            abc_dirs =[]
            abc_list_names = os.listdir(abc_path) if os.path.exists(abc_path) else []
            for a in abc_list_names:
                dir_path = os.path.join(abc_path, a)
                if os.path.isdir(dir_path):
                    abc_dirs.append(a)
            data['abc_dirs'] = abc_dirs

            # abc_file_list = os.listdir(abc_path) if os.path.exists(abc_path) else []
            # abc_file_list = os.listdir(abc_path) if os.path.exists(abc_path) else []
            # abc_list = []
            # for abc in abc_file_list:
            #     child_file = os.path.join(abc_path, abc)
            #     if os.path.isfile(child_file) and abc.startswith(shot_name):
            #         abc_list.append(abc)
            # data['abc_list'] = abc_list


    if pipeline == 'mod':  # 查模型有关系的窗口内容,
        mod_path = os.path.join(cgtw_path, 'Asset_work', 'Model')
        tex_path = os.path.join(cgtw_path, 'Asset_work', 'Texture')
        data = {'pipeline': 'mod', 'mod_path': '', 'mod_dirs': [], 'tex_path': '',
                'tex_dirs': []}  # {'pipeline':'mod','mod_path':Model目录,'mod_dirs':[dirs],'tex_path':Texture目录,'tex_dirs':[Texture目录下的abc]}
        if os.path.exists(mod_path):
            data['mod_path'] = mod_path
            mod_dirs_names = os.listdir(mod_path)
            mod_dirs = []
            for md in mod_dirs_names:
                dir_path = os.path.join(mod_path, md)
                if os.path.isdir(dir_path) and md != '.AppleDouble':
                    mod_dirs.append(md)
            data['mod_dirs'] = mod_dirs
        if os.path.exists(tex_path):
            data['tex_path'] = tex_path
            tex_dirs_names = os.listdir(tex_path)
            tex_dirs = []
            for td in tex_dirs_names:
                dir_path = os.path.join(tex_path, td)
                if os.path.isdir(dir_path) and td != '.AppleDouble':
                    tex_dirs.append(td)
            data['tex_dirs'] = tex_dirs

    if pipeline == 'rig':  # 查绑定有关系的窗口内容,
        rig_path = os.path.join(cgtw_path, 'Asset_work', 'Rig')
        data = {'pipeline': 'rig', 'rig_path': '',
                'rig_dirs': []}  # {'pipeline':'rig','rig_path':Rig目录,'rig_dirs':[dirs]}
        if os.path.exists(rig_path):
            data['rig_path'] = rig_path
            rig_dirs_names = os.listdir(rig_path)
            rig_dirs = []
            for r in rig_dirs_names:
                dir_path = os.path.join(rig_path, r)
                if os.path.isdir(dir_path) and r != '.AppleDouble':
                    rig_dirs.append(r)
            data['rig_dirs'] = rig_dirs

    if pipeline == 'env':  # 查场景有关系的窗口内容
        env_path = os.path.join(cgtw_path, 'Shot_work', 'Environment', eps, 'abc')
        data = {'pipeline': 'env', 'env_path': '',
                'abc_dirs': []}  # {'pipeline':'env','abc_path':abc目录(以shot_name过滤过),'abc_dirs':[dirs]}
        if os.path.exists(env_path):
            data['env_path'] = env_path
            abv_dirs_names = os.listdir(env_path)
            abc_dirs = []
            for ab in abv_dirs_names:
                dir_path = os.path.join(env_path, ab)
                if os.path.isdir(dir_path) and ab != '.AppleDouble' and ab.startswith(asset_shot_name):
                    abc_dirs.append(ab)
            data['abc_dirs'] = abc_dirs


    if pipeline == 'ani':
        asset_path = os.path.join(cgtw_path, 'Asset_work', 'Animation')
        # with open(r'F:\Temp\logs\asset_path.txt', 'w') as w:
        #     w.write(asset_path)

        shot_path = os.path.join(cgtw_path, 'Shot_work', 'Animation', eps, asset_shot_name, 'maya_file')
        abc_path = os.path.join(cgtw_path, 'Shot_work', 'Animation', eps, asset_shot_name, 'abc')
        data = {'pipeline': 'ani', 'asset_path': '', 'asset_dirs': [], 'shot_path': '', 'ma_list': [],
                'abc_path': '',
                'abc_dirs': []}  # {'pipeline':'ani','asset_path':Asset/Animation目录,'asset_dirs':[dirs],
        # 'shot_path':Shot镜头对应目录,'ma_list':[Shot目录下的ma],
        # 'abc_path':Shot镜头对应目录下的abc目录,'abc_dirs':[对应的各版本abc目录]}
        if os.path.exists(asset_path):
            data['asset_path'] = asset_path
            asset_list_name = os.listdir(asset_path)
            asset_dirs = []
            for ad in asset_list_name:
                dir_path = os.path.join(asset_path, ad)
                if os.path.isdir(dir_path) and ad != '.AppleDouble':
                    asset_dirs.append(ad)
            data['asset_dirs'] = asset_dirs
        if os.path.exists(shot_path):
            data['shot_path'] = shot_path
            ma_list_names = os.listdir(shot_path)
            ma_list = []
            for ma in ma_list_names:
                ma_path = os.path.join(shot_path, ma)
                if os.path.isfile(ma_path):
                    ma_list.append(ma)
            data['ma_list'] = ma_list
        if os.path.exists(abc_path):
            data['abc_path'] = abc_path
            abc_list_names = os.listdir(abc_path)
            abc_dirs = []
            for a in abc_list_names:
                dir_path = os.path.join(abc_path, a)
                if os.path.isdir(dir_path):
                    abc_dirs.append(a)
            data['abc_dirs'] = abc_dirs

    # if pipeline == 'lgt':  # 没有人阶段拿灯光文件
        # asset_path = os.path.join(cgtw_path, 'Asset_work', 'Light')
        #
        # shot_path = os.path.join(cgtw_path, 'Shot_work', 'Light', eps, asset_shot_name, 'maya_file')
        # abc_path = os.path.join(cgtw_path, 'Shot_work', 'Animation', eps, asset_shot_name, 'abc')
        # data = {'pipeline': 'ani', 'asset_path': '', 'asset_dirs': [], 'shot_path': '', 'ma_list': [],
        #         'abc_path': '',
        #         'abc_dirs': []}  # {'pipeline':'ani','asset_path':Asset/Animation目录,'asset_dirs':[dirs],
        # # 'shot_path':Shot镜头对应目录,'ma_list':[Shot目录下的ma],
        # # 'abc_path':Shot镜头对应目录下的abc目录,'abc_dirs':[对应的各版本abc目录]}
        # if os.path.exists(asset_path):
        #     data['asset_path'] = asset_path
        #     asset_list_name = os.listdir(asset_path)
        #     asset_dirs = []
        #     for ad in asset_list_name:
        #         dir_path = os.path.join(asset_path, ad)
        #         if os.path.isdir(dir_path) and ad != '.AppleDouble':
        #             asset_dirs.append(ad)
        #     data['asset_dirs'] = asset_dirs
        # if os.path.exists(shot_path):
        #     data['shot_path'] = shot_path
        #     ma_list_names = os.listdir(shot_path)
        #     ma_list = []
        #     for ma in ma_list_names:
        #         ma_path = os.path.join(shot_path, ma)
        #         if os.path.isfile(ma_path):
        #             ma_list.append(ma)
        #     data['ma_list'] = ma_list
        # if os.path.exists(abc_path):
        #     data['abc_path'] = abc_path
        #     abc_list_names = os.listdir(abc_path)
        #     abc_dirs = []
        #     for a in abc_list_names:
        #         dir_path = os.path.join(abc_path, a)
        #         if os.path.isdir(dir_path):
        #             abc_dirs.append(a)
        #     data['abc_dirs'] = abc_dirs




    return data